#include "string.h"

void test1()
{
	Mystring::string str("hello world");
	Mystring::string str2;
	cout << str2.c_str() << endl;

	std::cout << str.c_str() << std::endl;

	std::cout << str[1] << std::endl;

	Mystring::string::iterator it1 = str.begin();

	while (it1 != str.end())
	{
		std::cout << *it1 << " ";
		it1++;
	}
	std::cout << std::endl;

	for (auto e : str)
	{
		cout << e << " ";
	}
	std::cout << std::endl;
	str.push_back('a');
	cout << str.c_str() << endl;
	str.append("1111111");
	cout << str.c_str() << endl;
	str.insert(4, 'y');
	cout << str.c_str() << endl;
	str2.insert(0, "xxxxxxxxxxx");

	Mystring::string str3("hello world");
	str3.insert(6, "xx");
	cout << str3.c_str() << endl;
	str3.erase(6, 2);
	cout << str3.c_str() << endl;

	cout << str3.find('p', 0) << endl;
	cout << str3.find("wor", 0) << endl;
	cout << str3.c_str() << endl;

	Mystring::string str4(str3);
	cout << str4.c_str() << endl;
}

void test2()
{
	Mystring::string str1("hello world");
	cout << str1.c_str() << endl;

	Mystring::string str2(str1);
	cin >> str2;
	cout << str2.c_str() << endl;

	str1.swap(str2);
	cout << str1.c_str() << endl;
	cout << str2.c_str() << endl;

}

void test3()
{
	Mystring::string str1("hello world");
	Mystring::string str2;
	str2 = str1.substr(0, 5);
	cout << str2.c_str() << endl;

}

void test_string6()
{
	Mystring::string url("https://gitee.com/ailiangshilove/cpp-class/blob/master/%E8%AF%BE%E4%BB%B6%E4%BB%A3%E7%A0%81/C++%E8%AF%BE%E4%BB%B6V6/string%E7%9A%84%E6%8E%A5%E5%8F%A3%E6%B5%8B%E8%AF%95%E5%8F%8A%E4%BD%BF%E7%94%A8/TestString.cpp");
	size_t pos1 = url.find(':');
	Mystring::string url1 = url.substr(0, pos1 - 0);
	cout << url1.c_str() << endl;

	size_t pos2 = url.find('/', pos1 + 3);
	Mystring::string url2 = url.substr(pos1 + 3, pos2 - (pos1 + 3));
	cout << url2.c_str() << endl;

	Mystring::string url3 = url.substr(pos2 + 1);
	cout << url3.c_str() << endl;
}

void test4()
{
	Mystring::string str;
	cin >> str;
	cout << str.c_str() << endl;
	Mystring::string str2;
	str2 = str;
	Mystring::string str3(str2);
	cout << str2.c_str() << endl;
	cout << str3.c_str() << endl;

}

int main()
{
	test4();

	return 0;
}